<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>xmake插件开发之类库使用</title>
    <meta name="description" content="xmake通过import接口，可以在自定义脚本中导入各种内置类库和扩展类库模块，使得xmake的插件开发具有更多的灵活性，提供更丰富的功能。我们先看下，目前xmake提供的一些类库：">

    
    <meta name="keywords" content="xmake,插件,类库,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/2016/07/07/plugin-modules/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>xmake插件开发之类库使用</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2016-07-07
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#%E6%8F%92%E4%BB%B6" title="Tag: 插件" rel="tag">插件</a-->
        <a href="/cn/tag/#插件" title="Tag: 插件" rel="tag">插件</a>&nbsp;
    
        <!--a href="/tag/#%E7%B1%BB%E5%BA%93" title="Tag: 类库" rel="tag">类库</a-->
        <a href="/cn/tag/#类库" title="Tag: 类库" rel="tag">类库</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p>xmake通过import接口，可以在自定义脚本中导入各种内置类库和扩展类库模块，使得xmake的插件开发具有更多的灵活性，提供更丰富的功能。</p>

<p>我们先看下，目前xmake提供的一些类库：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>    .
    ├── _g.lua
    ├── assert.lua
    ├── catch.lua
    ├── coroutine.lua
    ├── debug.lua
    ├── finally.lua
    ├── format.lua
    ├── ifelse.lua
    ├── import
    │   └── core
    │       ├── base
    │       │   └── option.lua
    │       ├── platform
    │       │   ├── environment.lua
    │       │   ├── menu.lua
    │       │   └── platform.lua
    │       ├── project
    │       │   ├── cache.lua
    │       │   ├── config.lua
    │       │   ├── global.lua
    │       │   ├── history.lua
    │       │   ├── menu.lua
    │       │   ├── package.lua
    │       │   ├── project.lua
    │       │   ├── target.lua
    │       │   ├── task.lua
    │       │   └── template.lua
    │       └── tool
    │           ├── compiler.lua
    │           ├── linker.lua
    │           └── tool.lua
    ├── import.lua
    ├── inherit.lua
    ├── insert.lua
    ├── io.lua
    ├── ipairs.lua
    ├── math.lua
    ├── os.lua
    ├── pairs.lua
    ├── path.lua
    ├── print.lua
    ├── printf.lua
    ├── raise.lua
    ├── string.lua
    ├── table.lua
    ├── tonumber.lua
    ├── tostring.lua
    ├── try.lua
    ├── utils.lua
    └── vformat.lua
</code></pre>
</div>

<p>在根目录下的模块和api都是属于内建的，不需要import也可以直接使用，属于常用api，提供了xmake最基础的特性。。</p>

<p>在子目录下的是扩展模块，需要import后才能使用，导入规则见<a href="/cn/2016/06/09/api-import/">import</a>，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="n">import</span><span class="p">(</span><span class="s2">"core.project.task"</span><span class="p">)</span>
</code></pre>
</div>

<p>需要注意的是：xmake对自定义的脚本采用了异常处理机制，大部分情况下，调用的api是不需要判断返回值状态是否成功，如果出错了，会立即中断，并且显示错误信息</p>

<p>这样语法上更加的精简可读，并且更安全，所有api的输入输出，内部都有检测，状态不对会立即自动报错。</p>

<p>当然如果我们想要自己获取这个异常的状态，做一些逻辑上的处理，可以通过try/catch来实现，使用起来也非常简单。</p>

<p>下面简单介绍下一些常用的内置模块api，这些模块不需要import就可以使用的哦。：）</p>

<h4 id="os模块">os模块</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="c1">-- 运行shell命令，如果运行失败直接中断，并显示出错信息，我们不需要判断返回值</span>
    <span class="n">os</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"echo hello xmake!"</span><span class="p">)</span>

    <span class="c1">-- 复制文件</span>
    <span class="n">os</span><span class="p">.</span><span class="n">cp</span><span class="p">(</span><span class="s2">"/tmp/src"</span><span class="p">,</span> <span class="s2">"/tmp/dst"</span><span class="p">)</span>

    <span class="c1">-- 删除文件或者目录</span>
    <span class="n">os</span><span class="p">.</span><span class="n">rm</span><span class="p">(</span><span class="s2">"/tmp/dir"</span><span class="p">)</span>

    <span class="c1">-- 移动文件</span>
    <span class="n">os</span><span class="p">.</span><span class="n">mv</span><span class="p">(</span><span class="s2">"/tmp/old"</span><span class="p">,</span> <span class="s2">"/tmp/new"</span><span class="p">)</span>

    <span class="c1">-- 判断文件是否存在</span>
    <span class="k">if</span> <span class="n">os</span><span class="p">.</span><span class="n">isfile</span><span class="p">(</span><span class="s2">"/tmp/file"</span><span class="p">)</span> <span class="k">then</span>
    <span class="k">end</span>

    <span class="c1">-- 判断目录是否存在</span>
    <span class="k">if</span> <span class="n">os</span><span class="p">.</span><span class="n">isdir</span><span class="p">(</span><span class="s2">"/tmp/dir"</span><span class="p">)</span> <span class="k">then</span>
    <span class="k">end</span>

    <span class="c1">-- 匹配遍历文件，*为非递归匹配，**为递归匹配</span>
    <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">file</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">os</span><span class="p">.</span><span class="n">match</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">))</span> <span class="k">do</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
    <span class="k">end</span>

    <span class="c1">-- 匹配遍历目录，*为非递归匹配，**为递归匹配</span>
    <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">file</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">os</span><span class="p">.</span><span class="n">match</span><span class="p">(</span><span class="s2">"src/*"</span><span class="p">,</span> <span class="kc">true</span><span class="p">))</span> <span class="k">do</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
    <span class="k">end</span>
</code></pre>
</div>

<h4 id="常用api">常用api</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="c1">-- 抛出异常，立即中断</span>
    <span class="n">raise</span><span class="p">()</span>

    <span class="c1">-- 抛出异常，立即中断，并抛出异常错误信息</span>
    <span class="n">raise</span><span class="p">(</span><span class="s2">"error info"</span><span class="p">)</span>

    <span class="c1">-- 抛出异常，立即中断，并抛出异常错误代码</span>
    <span class="n">raise</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="c1">-- 显示输出并换行，支持格式化输出，跟lua的print稍有不同</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">"hello %s"</span><span class="p">,</span> <span class="s2">"xmake"</span><span class="p">)</span>

    <span class="c1">-- 显示输出不换行</span>
    <span class="n">printf</span><span class="p">(</span><span class="s2">"hello %s"</span><span class="p">,</span> <span class="s2">"xmake"</span><span class="p">)</span>

    <span class="c1">-- 格式化字符串</span>
    <span class="n">s</span> <span class="o">=</span> <span class="n">format</span><span class="p">(</span><span class="s2">"hello %s"</span><span class="p">,</span> <span class="s2">"xmake"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="异常捕获api">异常捕获api</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="n">try</span>
    <span class="p">{</span>
        <span class="c1">-- try块，里面抛出异常</span>
        <span class="k">function</span> <span class="p">()</span>
            <span class="n">raise</span><span class="p">(</span><span class="s2">"error"</span><span class="p">)</span>
        <span class="k">end</span><span class="p">,</span>

        <span class="n">catch</span>
        <span class="p">{</span>
            <span class="c1">-- catch块，捕获异常</span>
            <span class="k">function</span> <span class="p">(</span><span class="n">errors</span><span class="p">)</span>
                <span class="nb">print</span><span class="p">(</span><span class="n">errors</span><span class="p">)</span>
            <span class="k">end</span>
        <span class="p">}</span>
    <span class="p">}</span>

    <span class="c1">-- 获取try块的返回值，如果没有异常的话返回true</span>
    <span class="kd">local</span> <span class="n">ok</span> <span class="o">=</span> <span class="n">try</span>
    <span class="p">{</span>
        <span class="c1">-- try块，里面抛出异常</span>
        <span class="k">function</span> <span class="p">()</span>
            <span class="c1">-- may be error</span>
            <span class="k">return</span> <span class="kc">true</span>
        <span class="k">end</span>
    <span class="p">}</span>

    <span class="n">try</span>
    <span class="p">{</span>
        <span class="c1">-- try块，里面抛出异常</span>
        <span class="k">function</span> <span class="p">()</span>
            <span class="n">raise</span><span class="p">(</span><span class="s2">"error"</span><span class="p">)</span>
        <span class="k">end</span><span class="p">,</span>

        <span class="n">catch</span>
        <span class="p">{</span>
            <span class="c1">-- catch块，捕获异常</span>
            <span class="k">function</span> <span class="p">(</span><span class="n">errors</span><span class="p">)</span>
                <span class="nb">print</span><span class="p">(</span><span class="n">errors</span><span class="p">)</span>
            <span class="k">end</span>
        <span class="p">},</span>

        <span class="n">finally</span>
        <span class="p">{</span> 
            <span class="c1">-- finally 块</span>
            <span class="k">function</span> <span class="p">()</span>
            <span class="k">end</span>
        <span class="p">}</span>
    <span class="p">}</span>
</code></pre>
</div>

<h4 id="path模块">path模块</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="c1">-- 获取相对路径</span>
    <span class="n">path</span><span class="p">.</span><span class="n">relative</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">)</span>

    <span class="c1">-- 获取绝对路径</span>
    <span class="n">path</span><span class="p">.</span><span class="n">absolute</span><span class="p">(</span><span class="s2">"src"</span><span class="p">)</span>

    <span class="c1">-- 获取目录</span>
    <span class="n">path</span><span class="p">.</span><span class="n">directory</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">)</span>

    <span class="c1">-- 获取文件名 test.c</span>
    <span class="n">path</span><span class="p">.</span><span class="n">filename</span><span class="p">(</span><span class="s2">"/tmp/test.c"</span><span class="p">)</span>

    <span class="c1">-- 获取base名 test</span>
    <span class="n">path</span><span class="p">.</span><span class="n">basename</span><span class="p">(</span><span class="s2">"/tmp/test.c"</span><span class="p">)</span>

    <span class="c1">-- 获取扩展名</span>
    <span class="n">path</span><span class="p">.</span><span class="n">extension</span><span class="p">(</span><span class="s2">"/tmp/test.c"</span><span class="p">)</span>

    <span class="c1">-- 拼接路径 /tmp/test.c</span>
    <span class="n">path</span><span class="p">.</span><span class="n">join</span><span class="p">(</span><span class="s2">"/tmp"</span><span class="p">,</span> <span class="s2">"test.c"</span><span class="p">)</span>
</code></pre>
</div>

<h4 id="io-模块">io 模块</h4>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="c1">-- 打开一个写文件</span>
    <span class="n">file</span> <span class="o">=</span> <span class="nb">io.open</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span>

    <span class="c1">-- 写文件数据</span>
    <span class="n">file</span><span class="p">:</span><span class="n">write</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>

    <span class="c1">-- 写文件格式化行</span>
    <span class="n">file</span><span class="p">:</span><span class="nb">print</span><span class="p">(</span><span class="s2">"hello %s"</span><span class="p">,</span> <span class="s2">"xmake"</span><span class="p">)</span>

    <span class="c1">-- 写文件格式化不换行</span>
    <span class="n">file</span><span class="p">:</span><span class="n">printf</span><span class="p">(</span><span class="s2">"hello %s"</span><span class="p">,</span> <span class="s2">"xmake"</span><span class="p">)</span>

    <span class="c1">-- 关闭文件</span>
    <span class="n">file</span><span class="p">:</span><span class="n">close</span><span class="p">()</span>

    <span class="c1">-- 序列化写一个lua对象到文件</span>
    <span class="n">io</span><span class="p">.</span><span class="n">save</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">,</span> <span class="n">object</span><span class="p">)</span>

    <span class="c1">-- 反序列化读取一个文件对象</span>
    <span class="n">object</span> <span class="o">=</span> <span class="n">io</span><span class="p">.</span><span class="n">load</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">)</span>

    <span class="c1">-- 读取文件数据，并显示</span>
    <span class="n">io</span><span class="p">.</span><span class="n">cat</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">)</span>

    <span class="c1">-- 模式替换文件内容, 替换空格字符为 "space"</span>
    <span class="n">io</span><span class="p">.</span><span class="n">gsub</span><span class="p">(</span><span class="s2">"/tmp/a"</span><span class="p">,</span> <span class="s2">"%s"</span><span class="p">,</span> <span class="s2">"space"</span><span class="p">)</span>
</code></pre>
</div>

<p>还有一些是lua的常用模块，这里就不多说了，例如：<code class="highlighter-rouge">string, table, debug, coroutine, pairs, ipairs, tostring, tonumber</code> 等等</p>


        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        

        
        
            
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">相关文章</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
            
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/2016/07/07/plugin-lua/">插件使用之加载自定义lua脚本</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2016/07/12/includes-check/">头文件自动依赖检测和构建</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
